<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 

    <base href="<%=basePath%>">
    
    <title>My JSP 'manageBox.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
<%@ include file="validProgrammer.jsp" %>	
<link href="<%=request.getContextPath()%>/styles/table.css" rel="stylesheet" type="text/css" />
<% List<Box> boxes= new ArrayList<Box>(); %>
  </head>
  
  <body>
  
    <h1 align="center">箱格管理</h1> 
    
      <form action="<%=request.getContextPath()%>/programmer4Jsp">
    <input type="hidden" name="affair" value="searchBox" />
   自提柜编号： <input type="text" name="machine" style="display: inline;" />  
     箱格编号： <input type="text" name="id" style="display: inline;" />
      箱格状态： ： <select  name="state" style="display: inline;" > 
     <option value="1" >  空闲 </option>
       <option value="2" >  锁定 </option> 
        <option value="3" >  占用 </option> 
         <option value="4" >  故障 </option> 
       </select> 
     存放订单： <input type="text" name="orderID"  style="display: inline;" />  <br/>
    
    <input type="submit" value="搜索"> <br/>
    </form> 
    
    <table width="100%" class="tableA">
 <tr>  
 <th width="16%"  style="BACKGROUND-COLOR: #FF0000" >业主电话</th> 
   <th width="16%" style="BACKGROUND-COLOR: #FF0000"> 自提柜编号</th>  
   <th width="16%" style="BACKGROUND-COLOR: #FF0000"> 箱格编号</th>
    <th width="16%" style="BACKGROUND-COLOR: #FF0000"> 箱格状态</th>
      <th width="16%" style="BACKGROUND-COLOR: #FF0000"> 所放订单</th>
        <th width="16%" style="BACKGROUND-COLOR: #FF0000"> 操作</th>
     </tr> 
    <% boolean success; 
    Object temp =request.getAttribute("success");
     if(temp==null){
     success=false;
     }else{
       success= (Boolean) temp;
     }
    if(success) {
               request.removeAttribute("success");
     boxes= ( List<Box>) request.getSession().getAttribute("boxes"); }
    
   
        for (int i = 0; i < boxes.size(); i++) {     
             pageContext.setAttribute("box", boxes.get(i));  
             
            int state=boxes.get(i).getState(); 
              String stateWord=""; 
            if(state==1) stateWord="空闲";
            if(state==2) stateWord="预定";
            if(state==3) stateWord="占用";
            if(state==4) stateWord="锁定";
          
              pageContext.setAttribute("stateWord",stateWord); 
                pageContext.setAttribute("row", i % 2 != 0 ? "odd" : "even"); %>           
                       <tr>           
                                    <td>${box.owner}</td>               
                                    <td>${box.machine}</td>  
                                    <td>${box.id}</td>   
                                    <td><%=stateWord %></td>                                            
                                      <td>${box.orderID}</td>             
                                     
                       <td><a href="<%=request.getContextPath()%>/normalProgrammer/modifyBox.jsp?owner=${box.owner}&machine=${box.machine}&id=${box.id}&state=${box.state}&orderID=${box.orderID}" target="_blank">修改</a> 
                        </td>           
                             </tr> 
<%} %>
     </table>
  </body>
</html>
